<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>网站信息</title>  
    <link rel="stylesheet" href="admin/css/pintuer.css">
    <link rel="stylesheet" href="admin/css/admin.css">
    <script src="admin/js/jquery.js"></script>
    <script src="admin/js/pintuer.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#url1").change(function(){
    		//图片预览方法
    		var objUrl = getObjectURL(this.files[0]) ;
//     		console.log("objUrl = "+objUrl) ;
    		if (objUrl) {
    			$("#showImg").attr("src", objUrl) ;
    		}
    	});
    	$('#info_form').bind('submit',function(){
    		var formData = new FormData();
    		var file = $("#url1")[0].files[0];
    		if(file != null){
    			formData.append('file',file);
    		}
    		formData.append('id',$('input[name="id"]').val());
    		formData.append('title',$('input[name="title"]').val());
    		formData.append('domain',$('input[name="domain"]').val());
    		formData.append('keyword',$('textarea[name="keyword"]').val());
    		formData.append('descript',$('textarea[name="descript"]').val());
    		formData.append('owner',$('input[name="owner"]').val());
    		formData.append('phone',$('input[name="phone"]').val());
    		formData.append('telphone',$('input[name="telphone"]').val());
    		formData.append('email',$('input[name="email"]').val());
    		formData.append('address',$('input[name="address"]').val());
    		formData.append('footer',$('textarea[name="footer"]').val());
			$.ajax({
				url:'admin/uwebsiteinfo.do',
				type:'post',
				data:formData,
				dataType:'text',
				cache: false,  
		        contentType: false,  
		        processData: false,
				success:function(strValue){
					if(strValue.length > 0){
						$("#uresultdiv").css("display","block");
						$('#uresult').html(strValue);
					}
				}
			});
			return false;
		});
    });
  //建立一个可存取到该文件的URL
    function getObjectURL(file) {
    	var url = null ; 
    	if (window.createObjectURL!=undefined) { // basic
    		url = window.createObjectURL(file) ;
    	} else if (window.URL!=undefined) { // mozilla(firefox)
    		url = window.URL.createObjectURL(file) ;
    	} else if (window.webkitURL!=undefined) { // webkit or chrome
    		url = window.webkitURL.createObjectURL(file) ;
    	}
    	return url ;
    }
    </script>  
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 网站信息</strong></div>
  <div class="body-content">
    <form id="info_form" method="post" class="form-x" enctype="multipart/form-data">
    	<input type="hidden" name="id" value="${info.id }">
      <div class="form-group">
        <div class="label">
          <label>网站标题：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="title" value="${info.title }" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>LOGO预览：</label>
        </div>
        <div class="tip">
        	<img id="showImg" class="image" src="${info.logo }"/>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>更换LOGO：</label>
        </div>
        <div class="field">
          <input type="file" id="url1" name="logo" class="input tips" style="width:25%; float:left;" data-place="right" />
<!--           <input type="button" class="button bg-blue margin-left" id="image1" value="更换LOGO" > -->
        </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>网站域名：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="domain" value="${info.domain }" />
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>网站关键字：</label>
        </div>
        <div class="field">
          <textarea class="input" name="keyword" style="height:80px">${info.keyword }</textarea>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>网站描述：</label>
        </div>
        <div class="field">
          <textarea class="input" name="descript">${info.descript }</textarea>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>联系人：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="owner" value="${info.owner }" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>手机：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="phone" value="${info.phone }" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>电话：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="telphone" value="${info.telphone }" />
          <div class="tips"></div>
        </div>
      </div>
     
      <div class="form-group">
        <div class="label">
          <label>Email：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="email" value="${info.email }" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>地址：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="address" value="${info.address }" />
          <div class="tips"></div>
        </div>
      </div>  
              
      <div class="form-group">
        <div class="label">
          <label>底部信息：</label>
        </div>
        <div class="field">
          <textarea name="footer" class="input" style="height:120px;">${info.footer }</textarea>
          <div class="tips"></div>
        </div>
      </div>
      <div id="uresultdiv" class="form-group" style="display: none;">
        <div class="label">
          <label for="sitename">更新结果：</label>
        </div>
        <div class="label" style="width: 300px;">
          <div id="uresult" style="color:red;"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <input id="btn_submit" class="button bg-main icon-check-square-o" type="submit" value="提交"/>
        </div>
      </div>
    </form>
  </div>
</div>
</body></html>